/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package form;

import com.sun.lwuit.*;
import com.sun.lwuit.events.*;

import com.sun.lwuit.layouts.CoordinateLayout;
import helper.MobileDownloader;
import helper.Util;
import java.io.IOException;
import midlet.MainMidlet;

/**
 *
 * @author LegACy
 */
public class SecondForm extends ParentForm implements ActionListener {

    //Members
    private Label text_info;
    private Label rightBtn;

    /**
     * Main form constructor
     * @param midlet    The midlet which runs the form
     * @param parent    The previous form
     * @param items     An Array of item information.
     */
    public SecondForm(MainMidlet midlet, ParentForm parent) {
        super(midlet, parent, null);

        Image bg = null;
        String URL = null;
        try {
            URL = Util.getInstance().getBackgroung("menu");
            bg = Image.createImage(MobileDownloader.download(URL), 0, MobileDownloader.download(URL).length);
        } catch (Exception ex) {
            try {
                bg = Image.createImage(ParentForm.BG_IMAGE);
            } catch (IOException ex1) {
                System.out.println("Background image not found");
            }
        }
        //Configure form
        this.getStyle().setBgImage(bg);
        this.setLayout(new CoordinateLayout(Display.getInstance().getDisplayWidth(), Display.getInstance().getDisplayHeight()));

        //add text area

        text_info = new Label("This text of TNC");

        Font font = Font.createSystemFont(Font.FACE_SYSTEM, Font.STYLE_BOLD, Font.SIZE_LARGE);
        text_info.getStyle().setFont(font);
        text_info.getStyle().setBgTransparency(0);
        text_info.setX(0);
        text_info.setY(Display.getInstance().getDisplayHeight() / 2);



        this.addComponent(text_info);
        rightBtn = new Label("  back  ");
        rightBtn.setX(Display.getInstance().getDisplayWidth() - 60);
        rightBtn.setY(Display.getInstance().getDisplayHeight() - 25);
        rightBtn.getStyle().setBgTransparency(0);
        this.addComponent(rightBtn);

        //Add commands
//        this.addCommand(m_BackCmd);


        this.addCommandListener(this);
    }

    public void keyPressed(int keyCode) {
        super.keyPressed(keyCode);
        if (keyCode == -7) {
            if (rightBtn.getText().toString().trim().equals("back")) {
                this.disposeForm();
            }
        }
    }
}
